package classifier;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;

import learner.dtw.DTWModel;
import learner.hmm.HMMModel;

import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;

public class DTWModelReader {

private JsonReader reader;
	
	public DTWModelReader() {
	}
	
	public DTWModel giveModel(int patternNb){
		DTWModel model = readModel("models\\dtwmodel" + patternNb + ".json");
		return model;
	}
	
	public DTWModel readModel(String fileName) {
		ObjectInputStream in;
		try {
			in = new ObjectInputStream(new FileInputStream(fileName));
			DTWModel dtwmodel = (DTWModel)in.readObject();
			in.close();
			return dtwmodel;
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
			
		}
		catch (ClassNotFoundException e) {
			e.printStackTrace();
			return null;
		}
	}
}
